﻿<%@ Page MasterPageFile="Admin.Master" CodeBehind="Operations.aspx.cs"
    Inherits="BwanaBank.BankOnline.WinUI.Window.Admin.Operations" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <fieldset>
        <legend>Génération automatique des identifiants</legend>
        <p>
            <asp:TextBox ID="num" CssClass="textEntryAdmin" ReadOnly="True" placeholder="Numéro client"
                runat="server" />
            <asp:TextBox ID="code" CssClass="textEntryAdmin" ReadOnly="True" placeholder="Code secret"
                runat="server" />
            <asp:Button CssClass="loginEntryAdmin" runat="server" Text="Générer des identifiants aléatoires"
                OnClick="Random_Numbers" />
        </p>
    </fieldset>
    <div class="space">
    </div>
    <fieldset>
        <legend>Liste des clients à valider</legend>
        <asp:GridView ID="GridView2" runat="server" AllowSorting="True" AutoGenerateColumns="False"
            CellPadding="4" DataKeyNames="idUser" DataSourceID="NewUserDataSource" ForeColor="#333333"
            GridLines="None" Width="735px">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowEditButton="true" />
                <asp:BoundField DataField="lastName" HeaderText="Nom" SortExpression="lastName" />
                <asp:BoundField DataField="firstName" HeaderText="Prénom" SortExpression="firstName" />
                <asp:BoundField DataField="CustomerNum" HeaderText="Numéro client" />
                <asp:BoundField DataField="password" HeaderText="Mot de passe" />
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        <asp:SqlDataSource ID="NewUserDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:BWANABANKConnectionString %>"
            SelectCommand="SELECT [lastName],[firstName],[CustomerNum],[password], [idUser]FROM [User] where [idState] =1"
            UpdateCommand="update [User] set [lastName] =@lastName,  [firstName]=@firstName , [CustomerNum]=@CustomerNum, [password] = @password, [idState]=2  where idUser=@idUser ">
            <UpdateParameters>
                <asp:Parameter Name="lastName" Type="String" />
                <asp:Parameter Name="firstName" Type="String" />
                <asp:Parameter Name="CustomerNum" Type="string" />
                <asp:Parameter Name="password" Type="string" />
                <asp:Parameter Name="idUser" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </fieldset>
    <div class="space">
    </div>
    <fieldset>
        <legend>Liste des clients</legend>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
            CellPadding="4" DataKeyNames="idUser" DataSourceID="UserDataSource" ForeColor="#333333"
            GridLines="None" Width="735px">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" ShowEditButton="true" ShowDeleteButton="true" />
                <asp:BoundField DataField="lastName" HeaderText="Nom" SortExpression="lastName" />
                <asp:BoundField DataField="firstName" HeaderText="Prénom" SortExpression="firstName" />
                <asp:BoundField DataField="birthday" HeaderText="Date de naissance" />
                <asp:BoundField DataField="address" HeaderText="Adresse" />
                <asp:BoundField DataField="zipcode" HeaderText="Code postale" />
                <asp:BoundField DataField="country" HeaderText="Ville" />
                <asp:BoundField DataField="email" HeaderText="email" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:SqlDataSource ID="UserDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:BWANABANKConnectionString %>"
            SelectCommand="SELECT [civility], [lastName], [birthday], [address], [zipcode], [country], [email], [job], [salary], [firstName], [idUser] FROM [User]  where [idState] = 2"
            UpdateCommand="update [User] set [civility] = @civility, [lastName] =@lastName, [birthday]=@birthday, [address]=@address, [zipcode]=@zipcode, [country]=@country, [email]=@email, [job]=@job, [salary]=@salary, [firstName]=@firstName  where idUser=@idUser"
            DeleteCommand="delete from [User] where idUser=@idUser">
            <UpdateParameters>
                <asp:Parameter Name="civility" Type="String" />
                <asp:Parameter Name="lastName" Type="String" />
                <asp:Parameter Name="firstName" Type="String" />
                <asp:Parameter Name="birthday" Type="string" />
                <asp:Parameter Name="address" Type="String" />
                <asp:Parameter Name="zipcode" Type="String" />
                <asp:Parameter Name="country" Type="String" />
                <asp:Parameter Name="job" Type="String" />
                <asp:Parameter Name="salary" Type="String" />
                <asp:Parameter Name="email" Type="string" />
                <asp:Parameter Name="idUser" Type="Int32" />
            </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter Name="idUser" Type="Int32" />
            </DeleteParameters>
        </asp:SqlDataSource>
    </fieldset>
    <div class="space">
    </div>
    <fieldset>
        <legend>Détails du compte</legend>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="AccountDataSource"
            Height="50px" Width="735px" BackColor="LightGoldenrodYellow" BorderColor="Tan"
            BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
            <AlternatingRowStyle BackColor="PaleGoldenrod" />
            <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
            <Fields>
                <asp:BoundField DataField="idAccount" HeaderText="Numéro de compte" NullDisplayText="Inconnu"
                    SortExpression="idAccount" />
                <asp:BoundField DataField="realBalance" HeaderText="Solde réel" NullDisplayText="0€"
                    SortExpression="realBalance" />
            </Fields>
            <FooterStyle BackColor="Tan" />
            <HeaderStyle BackColor="Tan" Font-Bold="True" />
            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
        </asp:DetailsView>
        <asp:SqlDataSource ID="AccountDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:BWANABANKConnectionString %>"
            SelectCommand="SELECT [idAccount], [realBalance], [idUser] FROM [Account] where idUser = @idUser ">
            <SelectParameters>
                <asp:ControlParameter Name="idUser" ControlID="GridView1" />
            </SelectParameters>
        </asp:SqlDataSource>
    </fieldset>
</asp:Content>
